package com.yuxi.controller;

import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * redis使用
 * Created by yuxi on 16/11/1.
 */
@Controller
public class RedisController {
    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @Resource(name="redisTemplate")
    ValueOperations<Object,Object> valOps;



    @ApiOperation("添加缓存")
    @ApiImplicitParams({
    })
    @ApiResponses({
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 500, message = "内部服务错误")
    })
    @RequestMapping(value = "/set",method = RequestMethod.GET)
    @ResponseBody
    public Object setkey() {
        valOps.set("name","yuxi");
        return valOps.get("name");
    }
}
